package vista;
import java.awt.BorderLayout;
import java.awt.event.ActionListener;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaEquipo extends javax.swing.JFrame {
	private JPanel pancontenedor;
	private JLabel lblEquipos;
	private JLabel lblcodigo;
	private JLabel lblpais;
	private JButton btnconsultar;
	private JButton btnModificar;
	private JButton btnGuardar;
	private JLabel lblnadadores;
	private JTable tablanadadores;
	private JTextField txtnombre;
	private JTextField txtanno;
	private JComboBox cmbpais;
	private JTextField txtcodigo;
	private JLabel lblentrenador;
	private JLabel lblanno;
	private JScrollPane scplistado;
	private JButton btncargar;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	
	public VistaEquipo() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				pancontenedor = new JPanel();
				getContentPane().add(pancontenedor, BorderLayout.CENTER);
				pancontenedor.setLayout(null);
				{
					lblEquipos = new JLabel();
					pancontenedor.add(lblEquipos);
					lblEquipos.setText("Equipo");
					lblEquipos.setBounds(127, 6, 116, 21);
				}
				{
					lblcodigo = new JLabel();
					pancontenedor.add(lblcodigo);
					lblcodigo.setText("Codigo ");
					lblcodigo.setBounds(12, 47, 47, 15);
				}
				{
					lblpais = new JLabel();
					pancontenedor.add(lblpais);
					lblpais.setText("Pais que Representa");
					lblpais.setBounds(12, 74, 118, 15);
				}
				{
					lblanno = new JLabel();
					pancontenedor.add(lblanno);
					lblanno.setText("Año de Fundacion");
					lblanno.setBounds(12, 101, 118, 15);
				}
				{
					lblentrenador = new JLabel();
					pancontenedor.add(lblentrenador);
					lblentrenador.setText("Nombre del Entrenador");
					lblentrenador.setBounds(12, 128, 147, 15);
				}
				{
					txtcodigo = new JTextField();
					pancontenedor.add(txtcodigo);
					txtcodigo.setBounds(179, 44, 56, 22);
				}
				{
					cmbpais = new JComboBox();
					pancontenedor.add(cmbpais);
					cmbpais.setBounds(179, 70, 64, 22);
				}
				{
					txtanno = new JTextField();
					pancontenedor.add(txtanno);
					txtanno.setBounds(179, 98, 64, 22);
				}
				{
					txtnombre = new JTextField();
					pancontenedor.add(txtnombre);
					txtnombre.setBounds(171, 125, 72, 22);
				}
				{
				
						scplistado = new JScrollPane();
						pancontenedor.add(scplistado);
						scplistado.setBounds(357, 36, 355, 195);
					{
					tablanadadores = new JTable();
					scplistado.setViewportView(tablanadadores);
					}
				}
				{
					lblnadadores = new JLabel();
					pancontenedor.add(lblnadadores);
					lblnadadores.setText("Nadadores");
					lblnadadores.setBounds(388, 9, 160, 15);
				}
				{
					btnGuardar = new JButton();
					pancontenedor.add(btnGuardar);
					btnGuardar.setText("Guardar");
					btnGuardar.setBounds(12, 172, 65, 22);
				}
				{
					btnModificar = new JButton();
					pancontenedor.add(btnModificar);
					btnModificar.setText("Modificar");
					btnModificar.setBounds(109, 172, 70, 22);
				}
				{
					btnconsultar = new JButton();
					pancontenedor.add(btnconsultar);
					btnconsultar.setText("Consultar");
					btnconsultar.setBounds(12, 209, 74, 22);
				}
				{
					btncargar = new JButton();
					pancontenedor.add(btncargar);
					btncargar.setText("Limpiar");
					btncargar.setBounds(109, 209, 56, 22);
				}
			}
			pack();
			this.setSize(742, 342);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	public void agregarlistener (ActionListener action)
	{
		btnconsultar.addActionListener(action);
	
		btnGuardar.addActionListener(action);
		btnModificar.addActionListener(action);
		cmbpais.addActionListener(action);
		btncargar.addActionListener(action);
	}
	public void setpais (String[] paises)
	{
		ComboBoxModel cmbsetcombo = new DefaultComboBoxModel(paises);
		cmbpais.setModel(cmbsetcombo);
	}
	public String getcodigo()
	{
		return txtcodigo.getText();
	}
	public String getpais()
	{
		return cmbpais.getSelectedItem().toString();
	}
	public int getanno()
	{
		return Integer.parseInt((txtanno.getText()));
	}
	public String nombreentrenador()
	{
		return txtnombre.getText();
	}
	public void imprimirmensaje(String msj)
	{
		JOptionPane.showMessageDialog(this, msj);
	}
	public void setListado(AbstractTableModel abstractTableModel){
		tablanadadores.setModel(abstractTableModel);
	}
	public void blanquearCampos() {
		txtcodigo.setText("");
		txtanno.setText("");
		txtnombre.setText("");
	
	}

	public void setAnno(String anno) {
		txtanno.setText(anno);
		
	}

	public void setnombreentrenador(String entrenador) {
		// TODO Auto-generated method stub
		txtnombre.setText(entrenador);
	}

}
